<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
</head>

<body>

<div class="body">
  <g:if test="${projectInstance.name}">

    <gui:expandablePanel title="${projectInstance.name}" expanded="true">

      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <g:hasErrors bean="${projectInstance}">
        <div class="errors">
          <g:renderErrors bean="${projectInstance}" as="list"/>
        </div>
      </g:hasErrors>
      <g:form method="post" controller="project" action="updateProject">
        <g:hiddenField name="id" value="${projectInstance?.id}"/>
        <g:hiddenField name="version" value="${projectInstance?.version}"/>
        <div>
          <table>
            <tbody>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="name"><g:message code="project.name.label" default="Name"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'name', 'errors')}">
                <g:textField name="name" maxlength="200" value="${projectInstance?.name}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="description"><g:message code="project.description.label" default="Description"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'description', 'errors')}">
                <g:textArea name="description" cols="40" rows="5" value="${projectInstance?.description}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="projectType"><g:message code="project.projectType.label" default="Project Type"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectType', 'errors')}">
                <g:select name="projectType" from="${projectInstance.constraints.projectType.inList}" value="${projectInstance?.projectType}" valueMessagePrefix="project.projectType"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="projectSubType"><g:message code="project.projectSubType.label" default="Project Sub Type"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectSubType', 'errors')}">
                <g:select name="projectSubType" from="${projectInstance.constraints.projectSubType.inList}" value="${projectInstance?.projectSubType}" valueMessagePrefix="project.projectSubType"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="projectState"><g:message code="project.projectState.label" default="Project State"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectState', 'errors')}">
                <g:select name="projectState" from="${projectInstance.constraints.projectState.inList}" value="${projectInstance?.projectState}" valueMessagePrefix="project.projectState"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="startDate"><g:message code="project.startDate.label" default="Start Date"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'startDate', 'errors')}">
                <g:datePicker name="startDate" precision="day" value="${projectInstance?.startDate}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="endDate"><g:message code="project.endDate.label" default="End Date"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'endDate', 'errors')}">
                <g:datePicker name="endDate" precision="day" value="${projectInstance?.endDate}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="sharePointUrl"><g:message code="project.sharePointUrl.label" default="Share Point Url"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'sharePointUrl', 'errors')}">
                <g:textField name="sharePointUrl" value="${projectInstance?.sharePointUrl}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="wikiUrl"><g:message code="project.wikiUrl.label" default="Wiki Url"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'wikiUrl', 'errors')}">
                <g:textField name="wikiUrl" value="${projectInstance?.wikiUrl}"/>
              </td>
            </tr>

            %{--<tr class="prop">--}%
            %{--<td valign="top" class="name">--}%
            %{--<label for="forecast"><g:message code="project.forecast.label" default="Forecast" /></label>--}%
            %{--</td>--}%
            %{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'forecast', 'errors')}">--}%

            %{--<ul>--}%
            %{--<g:each in="${projectInstance?.forecast?}" var="f">--}%
            %{--<li><g:link controller="projectForecast" action="show" id="${f.id}">${f?.encodeAsHTML()}</g:link></li>--}%
            %{--</g:each>--}%
            %{--</ul>--}%
            %{--<g:link controller="projectForecast" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectForecast.label', default: 'ProjectForecast')])}</g:link>--}%

            %{--</td>--}%
            %{--</tr>--}%

            <tr class="prop">
              <td valign="top" class="name">
                <label for="projectAdmins"><g:message code="project.projectAdmins.label" default="Project Admins"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectAdmins', 'errors')}">
                <g:select name="projectAdmins" from="${com.portico.security.User.list()}" multiple="yes" optionKey="id" size="5" value="${projectInstance?.projectAdmins*.id}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="projectNumber"><g:message code="project.projectNumber.label" default="Project Number"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'projectNumber', 'errors')}">
                <g:textField name="projectNumber" value="${projectInstance?.projectNumber}"/>
              </td>
            </tr>



            %{--<tr class="prop">--}%
            %{--<td valign="top" class="name">--}%
            %{--<label for="releaseDetails"><g:message code="project.releaseDetails.label" default="Release Details" /></label>--}%
            %{--</td>--}%
            %{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'releaseDetails', 'errors')}">--}%

            %{--<ul>--}%
            %{--<g:each in="${projectInstance?.releaseDetails?}" var="r">--}%
            %{--<li><g:link controller="releaseDetail" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
            %{--</g:each>--}%
            %{--</ul>--}%
            %{--<g:link controller="releaseDetail" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'releaseDetail.label', default: 'ReleaseDetail')])}</g:link>--}%

            %{--</td>--}%
            %{--</tr>--}%

            %{--<tr class="prop">--}%
            %{--<td valign="top" class="name">--}%
            %{--<label for="risks"><g:message code="project.risks.label" default="Risks" /></label>--}%
            %{--</td>--}%
            %{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'risks', 'errors')}">--}%

            %{--<ul>--}%
            %{--<g:each in="${projectInstance?.risks?}" var="r">--}%
            %{--<li><g:link controller="projectRisks" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
            %{--</g:each>--}%
            %{--</ul>--}%
            %{--<g:link controller="projectRisks" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectRisks.label', default: 'ProjectRisks')])}</g:link>--}%

            %{--</td>--}%
            %{--</tr>--}%

            %{--<tr class="prop">--}%
            %{--<td valign="top" class="name">--}%
            %{--<label for="roster"><g:message code="project.roster.label" default="Roster" /></label>--}%
            %{--</td>--}%
            %{--<td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'roster', 'errors')}">--}%

            %{--<ul>--}%
            %{--<g:each in="${projectInstance?.roster?}" var="r">--}%
            %{--<li><g:link controller="projectTeamMember" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link></li>--}%
            %{--</g:each>--}%
            %{--</ul>--}%
            %{--<g:link controller="projectTeamMember" action="create" params="['project.id': projectInstance?.id]">${message(code: 'default.add.label', args: [message(code: 'projectTeamMember.label', default: 'ProjectTeamMember')])}</g:link>--}%

            %{--</td>--}%
            %{--</tr>--}%

            <tr class="prop">
              <td valign="top" class="name">
                <label for="sponsor"><g:message code="project.sponsor.label" default="Sponsor"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'sponsor', 'errors')}">
                <g:textField name="sponsor" value="${projectInstance?.sponsor}"/>
              </td>
            </tr>

            <tr class="prop">
              <td valign="top" class="name">
                <label for="technicalManager"><g:message code="project.technicalManager.label" default="Technical Manager"/></label>
              </td>
              <td valign="top" class="value ${hasErrors(bean: projectInstance, field: 'technicalManager', 'errors')}">
                <g:textField name="technicalManager" value="${projectInstance?.technicalManager}"/>
              </td>
            </tr>

            </tbody>
          </table>
        </div>
        <div class="buttons">
          <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}"/></span>
        </div>
      </g:form>
    </gui:expandablePanel>


    <gui:accordion>
      <g:each in="${projectInstance?.recurringStatus?}" var="r">
        <gui:accordionElement title="${r?.encodeAsHTML()}">
          <g:link controller="projectStatus" action="show" id="${r.id}">${r?.encodeAsHTML()}</g:link>
        </gui:accordionElement>
      </g:each>
      <gui:accordionElement title="Add">
        <g:link controller="projectStatus" action="create" params="['project.id': projectInstance?.id]">
          ${message(code: 'default.add.label', args: [message(code: 'projectStatus.label', default: 'ProjectStatus')])}</g:link>
      </gui:accordionElement>

    </gui:accordion>

  </g:if>

</div>

</body>
</html>